// 深拷贝
function deepCopy(obj) {
  let results;
  if (typeof obj === 'object') {
    if (Array.isArray(obj)) {
      results = [];
      for (let i = 0; i < obj.length; i++) {
        results.push(deepCopy(obj[i]))
      }
    } else if (obj === null) {
      results = null
    } else if (obj.constructor === RegExp) {
      results = obj
    } else {
      results = {}
      for (let key in obj) {
        results[key] = deepCopy(obj[key])
      }
    }
  } else {
    results = obj;
  }
  return results
}

const a = [
  { name: 'dayday' },
  {
    friends: [
      'dd',
      '33'
    ]
  },
  { age: null }
]

let b = deepCopy(a)
b[0].name = 'eeee'

console.log(a, b)

